package park.monitor;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


public class MonitorFrame extends JFrame
{
    public MonitorFrame() throws HeadlessException
    {
        this.setTitle("message Monitor");
        JScrollPane jscrollPane;
        this.getContentPane().add(jscrollPane = new JScrollPane(), BorderLayout.CENTER);

        JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        panel.setPreferredSize(
                new Dimension((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.8), 230));

        for (Sampler sampler : SAMPLERS)
        {
            Monitor monitor = new Monitor(sampler);
            monitor.surf.start();
            monitor.setPreferredSize(new Dimension(220, 180));
            panel.add(monitor);
        }
        jscrollPane.getViewport().add(panel);

        this.addWindowListener(new WindowAdapter()
        {
            @Override
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        });

        this.pack();
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    }

    public static final Sampler[] SAMPLERS = new Sampler[]{new CheckFreeVehicleSampler()};
}
